import {createRouter, createWebHistory} from 'vue-router'

import addBlog  from '../views/AddBlog.vue'
import EditBlog from '@/views/EditBlog.vue'
import ListBlog from '@/views/ListBlog.vue'
import SingleBlog from '@/views/SingleBlog.vue'

const routes = [
    {
        path:'/',
        name:'index',
        redirect: '/blog/list'
    },
    //添加博客
    {
        path: '/blog/add',
        name: 'add-Blog',
        component: addBlog
    },
    //编辑博客
    {
        path: '/blog/edit/:id',
        name: 'Edit-Blog',
        component: EditBlog,
        props: true
    },
    //分页显示博客
    {
        path: '/blog/list',
        name: 'List-Blog',
        component: ListBlog
    },
    //显示指定博客
    {
        path: '/blog/view/:id',
        name: 'Single-Blog',
        component: SingleBlog,
         props: true
    }
]
const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router